<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
  <script src="./js/template-web.js"></script>
</head>
<body>
  <h1>获取天气预报信息</h1>
  <div id="a"></div>
  <script type="text/html" id="tpl">
    最高气温:{{result.temphigh}}, 最低气温:{{result.templow}},
    平均气温:{{result.temp}}, 风向{{result.winddirect}}  
    风力{{result.windpower}}   风速{{result.windspeed}} 

    城市：{{result.city}}
    未来一周天气情况：
    {{each result.daily value}}
      {{value.date}}
      {{value.week}}
      {{value.day.weather}}
      {{value.day.temphigh}}℃
    {{/each}}
  </script>
  <script>
    $.ajax({
      url:"https://api.jisuapi.com/weather/query",
      data:"appkey=1dc381f43936cdf7&city=北京",
      type:"get",
      dataType:"jsonp",
      jsonp:"callback",
      success:function(data){
        console.log(data)
        const str = template("tpl",data)
        document.getElementById('a').innerText=str
        // $("#a").text(str)
      }
    })
  </script>
</body>
</html>